package com.example.beacondemo;

import android.Manifest;
import android.app.Application;
import android.content.pm.PackageManager;
import android.os.Build;
import android.util.Log;

import org.altbeacon.beacon.BeaconManager;
import org.altbeacon.beacon.BeaconParser;
import org.altbeacon.beacon.Region;
import org.altbeacon.beacon.powersave.BackgroundPowerSaver;
import org.altbeacon.beacon.startup.BootstrapNotifier;
import org.altbeacon.beacon.startup.RegionBootstrap;

public class MyApp extends Application implements BootstrapNotifier {

    private RegionBootstrap regionBootstrap;
    private BackgroundPowerSaver backgroundPowerSaver;
    private BeaconManager beaconManager;
    @Override
    public void onCreate() {
        super.onCreate();
        beaconManager = BeaconManager.getInstanceForApplication(MyApp.this);
        beaconManager.getBeaconParsers().clear();
        beaconManager.getBeaconParsers().add(new BeaconParser()
                .setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"));



        Region region = new Region("all-region-beacon",null,null,null);
        regionBootstrap = new RegionBootstrap(this,region);
        backgroundPowerSaver = new BackgroundPowerSaver(this);
    }

    @Override
    public void didEnterRegion(Region region) {
        Log.d("MyApp",region.getBluetoothAddress()+"");
    }

    @Override
    public void didExitRegion(Region region) {
        Log.d("MyApp",region.getBluetoothAddress()+"");
    }

    @Override
    public void didDetermineStateForRegion(int i, Region region) {
        Log.d("MyApp",region.getBluetoothAddress()+"");
    }
}
